﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace Numero3DBObject
{
    [Serializable()]
    public class Cours
    {
        private string sigle;
        private string nom;
        private string description;
        private double credit;

        public Cours() { }

        public Cours(string _sigle, string _nom, string _description, double _credit) 
        {
            sigle = _sigle;
            nom = _nom;
            description = _description;
            credit = _credit;
        }

        public string Sigle
        {
            get { return sigle; }
            set { sigle = value; }
        }

        public string Nom
        {
            get { return nom; }
            set { nom = value; }
        }

        public string Description
        {
            get { return description; }
            set { description = value; }
        }

        public double Credit
        {
            get { return credit; }
            set { credit = value; }
        }


        public static bool operator ==(Cours c1, Cours c2)
        {
            //Contract.Requires(c1 != null, "L'objet c1 est null.");
            //Contract.Requires(c2 != null, "L'objet c2 est null.");

            try
            {
                bool identique = false;
                if (c1.sigle.Equals(c2.sigle)
                    && c1.nom.Equals(c2.nom)
                    && c1.description.Equals(c2.description)
                    && c1.credit.Equals(c2.credit))
                {
                    identique = true;
                }

                return identique;
            }
            catch (NullReferenceException e)
            {
                
                throw e;
            }

        }


        public static bool operator !=(Cours c1, Cours c2)
        {
            //Contract.Requires(c1 != null, "L'objet c1 est null.");
            //Contract.Requires(c2 != null, "L'objet c2 est null.");

            try
            {
                bool different = false;
                if (!(c1.sigle.Equals(c2.sigle)
                    && c1.nom.Equals(c2.nom)
                    && c1.description.Equals(c2.description)
                    && c1.credit.Equals(c2.credit)))
                {
                    different = true;
                }

                return different;
            }
            catch (NullReferenceException e)
            {
                throw e;
            }
            
        }


        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
